package alo;

/**
 * @ClassName t11
 * @Description TODO
 * @Author Fanxc
 * @DATE 2021/4/20 22:28
 * @Version 1.0
 */
public class t11 {

    public class ListNode {
        int val;
        ListNode next;
        ListNode(int x) { val = x; }
    }
    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        if (pHead1==null||pHead2==null)return null;
        ListNode c1=pHead1;
        ListNode c2=pHead2;
        while (c1!=c2){
            c1=c1==null?pHead2:c1.next;
            c2=c2==null?pHead1:c2.next;
        }
        return c1;
    }

}
